package com.sdtv.basemodule.widget.gloading;

import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.drawable.AnimationDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sdtv.basemodule.R;

/**
 * @ProjectName: MediunFusion
 * @Package: com.sdtv.basemodule.widget.gloading
 * @ClassName: GloadingLoadingView
 * @Description: 加载中view
 * @Author: 小郭同学
 * @CreateDate: 2019-06-20 09:40
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class GloadingLoadingView extends LinearLayout {

    public GloadingLoadingView(Context context) {
        this(context,null);
    }

    public GloadingLoadingView(Context context, String str) {
        super(context);
        LayoutInflater.from(context).inflate(R.layout.loading_view_layout, this, true);

        if (str != null && !str.isEmpty()) {
            TextView tv = findViewById(R.id.sdmtv_loading_dialog_message);
            tv.setText(str);
        }
        ImageView imageView = findViewById(R.id.sdmtv_loading_image);
        // 旋转动画
        ObjectAnimator rotation = ObjectAnimator.ofFloat(imageView, "rotation", 0f, 359f);
        rotation.setRepeatCount(ObjectAnimator.INFINITE);
        rotation.setInterpolator(new LinearInterpolator());
        rotation.setDuration(1000);
        rotation.start();

    }
}
